home *** CD-ROM | disk | FTP | other *** search
/ Macwelt 4 / Macwelt DVD 4.cdr / Entwickler / Mac-OS / oxygen / oxygen.app / Contents / Resources / Java / jh.jar / javax / help / FlatMap$FlatMapResourceBundle.class (.txt) < prev    next >
Encoding:
Java Class File  |  2002-06-24  |  4.5 KB  |  172 lines

  1. package javax.help;
  2.  
  3. import com.sun.java.help.impl.Parser;
  4. import com.sun.java.help.impl.ParserEvent;
  5. import com.sun.java.help.impl.ParserListener;
  6. import com.sun.java.help.impl.Tag;
  7. import com.sun.java.help.impl.TagProperties;
  8. import com.sun.java.help.impl.XmlReader;
  9. import java.io.IOException;
  10. import java.io.Reader;
  11. import java.net.URL;
  12. import java.net.URLConnection;
  13. import java.util.Enumeration;
  14. import java.util.Hashtable;
  15. import java.util.ResourceBundle;
  16. import java.util.Vector;
  17.  
  18. public class FlatMap$FlatMapResourceBundle extends ResourceBundle implements ParserListener {
  19.    private Hashtable lookup;
  20.    private boolean startedmap;
  21.    private URL source;
  22.    private Vector messages;
  23.    private boolean validParse;
  24.    // $FF: synthetic field
  25.    private final FlatMap this$0;
  26.  
  27.    public FlatMap$FlatMapResourceBundle(FlatMap var1, URL var2) {
  28.       this.this$0 = var1;
  29.       this.lookup = null;
  30.       this.messages = new Vector();
  31.       this.validParse = true;
  32.       this.source = var2;
  33.  
  34.       try {
  35.          URLConnection var4 = var2.openConnection();
  36.          Reader var3 = XmlReader.createReader(var4);
  37.          this.parse(var3);
  38.          var3.close();
  39.       } catch (Exception var7) {
  40.          this.reportMessage("Exception caught while parsing " + var2 + " " + var7.toString(), false);
  41.       }
  42.  
  43.       this.parsingEnded();
  44.  
  45.       String var5;
  46.       String var6;
  47.       for(Enumeration var8 = this.lookup.keys(); var8.hasMoreElements(); var6 = (String)this.lookup.get(var5)) {
  48.          var5 = (String)var8.nextElement();
  49.       }
  50.  
  51.    }
  52.  
  53.    public final Object handleGetObject(String var1) {
  54.       return this.lookup.get(var1);
  55.    }
  56.  
  57.    public Enumeration getKeys() {
  58.       return this.lookup.keys();
  59.    }
  60.  
  61.    synchronized void parse(Reader var1) throws IOException {
  62.       this.lookup = new Hashtable(10);
  63.       Parser var2 = new Parser(var1);
  64.       var2.addParserListener(this);
  65.       var2.parse();
  66.    }
  67.  
  68.    public void tagFound(ParserEvent var1) {
  69.       Object var2 = null;
  70.       Tag var3 = var1.getTag();
  71.       FlatMap.access$000("TagFound: " + var3.name);
  72.       TagProperties var4 = var3.atts;
  73.       if (var3.name.equals("mapID")) {
  74.          if (!this.startedmap) {
  75.             this.parsingError("map.invalidMapFormat");
  76.          }
  77.  
  78.          String var7 = null;
  79.          String var6 = null;
  80.          if (var4 != null) {
  81.             var7 = var4.getProperty("target");
  82.             var6 = var4.getProperty("url");
  83.          }
  84.  
  85.          if (var7 != null && var6 != null) {
  86.             this.lookup.put(var7, var6);
  87.          } else {
  88.             this.reportMessage("Failure in mapID Creation;", true);
  89.             this.reportMessage("  target: " + var7, true);
  90.             this.reportMessage("  url: " + var6, true);
  91.          }
  92.       } else if (var3.name.equals("map")) {
  93.          if (!var3.isEnd) {
  94.             if (var4 != null) {
  95.                String var5 = var4.getProperty("version");
  96.                if (var5 != null && var5.compareTo("1.0") != 0) {
  97.                   this.parsingError("map.unknownVersion", var5);
  98.                }
  99.             }
  100.  
  101.             if (this.startedmap) {
  102.                this.parsingError("map.invalidMapFormat");
  103.             }
  104.  
  105.             this.startedmap = true;
  106.          } else if (this.startedmap) {
  107.             this.startedmap = false;
  108.          }
  109.  
  110.       }
  111.    }
  112.  
  113.    public void piFound(ParserEvent var1) {
  114.    }
  115.  
  116.    public void doctypeFound(ParserEvent var1) {
  117.       String var2 = var1.getPublicId();
  118.       if (var2 == null || !var2.equals("-//Sun Microsystems Inc.//DTD JavaHelp Map Version 1.0//EN")) {
  119.          this.parsingError("map.wrongPublicID", var2);
  120.       }
  121.  
  122.    }
  123.  
  124.    public void textFound(ParserEvent var1) {
  125.    }
  126.  
  127.    public void commentFound(ParserEvent var1) {
  128.    }
  129.  
  130.    public void errorFound(ParserEvent var1) {
  131.       this.reportMessage(var1.getText(), false);
  132.    }
  133.  
  134.    public void reportMessage(String var1, boolean var2) {
  135.       this.messages.addElement(var1);
  136.       this.validParse = this.validParse && var2;
  137.    }
  138.  
  139.    public Enumeration listMessages() {
  140.       return this.messages.elements();
  141.    }
  142.  
  143.    private void parsingEnded() {
  144.       if (!this.validParse) {
  145.          if (this.lookup != null) {
  146.             this.lookup.clear();
  147.          }
  148.  
  149.          FlatMap.access$000("Parsing failed for " + this.source);
  150.          Enumeration var1 = this.messages.elements();
  151.  
  152.          while(var1.hasMoreElements()) {
  153.             String var2 = (String)var1.nextElement();
  154.             FlatMap.access$000(var2);
  155.          }
  156.       } else {
  157.          this.source = null;
  158.       }
  159.  
  160.    }
  161.  
  162.    private void parsingError(String var1) {
  163.       String var2 = HelpUtilities.getText(var1);
  164.       this.reportMessage(var2, false);
  165.    }
  166.  
  167.    private void parsingError(String var1, String var2) {
  168.       String var3 = HelpUtilities.getText(var1, var2);
  169.       this.reportMessage(var3, false);
  170.    }
  171. }
  172.